#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int i,len1, len2,num,numtmp,num1[1000], num2[1000];
	while (cin >> num)
	{
		if (!num)
		{
			cout << "0" << endl << "0" << endl;
			continue;
		}
		numtmp = num;
		len1 = len2 = 0;
		while (num)
		{
			num1[len1++] = num % 2;
			num /= 2;
		}
		for (i = len1 - 1; i >= 0; i--)cout << num1[i];
		cout << endl;
		num = numtmp;
		while (num)
		{
			num2[len2++] = num % 8;
			num /= 8;
		}
		for (i = len2 - 1; i >= 0; i--)cout << num2[i];
		cout << endl;
	}
	return 0;
}